package com.bootssm.service.impl;

import com.bootssm.dao.CategoryMapper;
import com.bootssm.pojo.Category;
import com.bootssm.pojo.CategoryVO;
import com.bootssm.service.CategoryService;
import com.bootssm.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryMapper categoryMapper;

    @Override
    public List<Category> findAll(CategoryVO categoryVO) {
        return categoryMapper.findAll(categoryVO);
    }

    @Override
    public Integer getCount(CategoryVO categoryVO) {
        return categoryMapper.getCount(categoryVO);
    }

    @Autowired
    IdWorker idWorker;

    @Override
    public void insert(Category category) {
        category.setCategoryId(idWorker.nextId()+"");
        categoryMapper.insert(category);
    }

    @Override
    public Category findById(String categoryId) {
        return categoryMapper.findById(categoryId);
    }

    @Override
    public void update(Category category) {
        categoryMapper.update(category);
    }

    @Override
    public void delete(String categoryId) {
        categoryMapper.delete(categoryId);
    }

    @Override
    public List<Category> select() {
        return categoryMapper.select();
    }


}
